<template>
  <a-card :bordered="true" style="margin-bottom: 30px" title="普通选择框">
    <a-row style="margin-bottom: 10px">
      <a-col :span="4">
        <div class="example-side">
          demo1:单选(必须是option的格式)
        </div>
      </a-col>
      <a-col :span="8">
        <div class="example-side">
          <!--------------------------------------------------------------------------------------demo1---start-->
          <a-select
            :options="typeList"
            placeholder="请选择类型"
            style="width: 60%"
            v-model="demo1.select1"
          />
          <!--------------------------------------------------------------------------------------demo1---end-->
          <a-button @click="() => demo1.select1 = undefined" style="margin-left: 8px">重置</a-button>
        </div>
      </a-col>
      <a-col :span="12" class="example-side">
        <div>
          当前选择: {{ demo1.select1 }}
        </div>
        <div>
          当前显示: {{ demo1.select1 | dictFilter(typeList) }}
        </div>
      </a-col>
    </a-row>

    <a-row style="margin-bottom: 10px">
      <a-col :span="4">
        <div class="example-side">
          demo2:单选(第二种写法)
        </div>
      </a-col>
      <a-col :span="8">
        <div class="example-side">
          <!--------------------------------------------------------------------------------------demo2---start-->
          <a-select
            placeholder="请选择类型"
            style="width: 60%;"
            v-model="demo2.select1"
          >
            <a-select-option :key="index" :value="item.value" v-for="(item,index) in typeList">{{ item.label }}
            </a-select-option>
          </a-select>
          <!--------------------------------------------------------------------------------------demo2---end-->
          <a-button @click="() => demo2.select1 = undefined" style="margin-left: 8px">重置</a-button>
        </div>
      </a-col>
      <a-col :span="12" class="example-side">
        <div>
          当前选择: {{ demo2.select1 }}
        </div>
        <div>
          当前显示: {{ demo2.select1 | dictFilter(typeList) }}
        </div>
      </a-col>
    </a-row>

    <a-row style="margin-bottom: 10px">
      <a-col :span="4">
        <div class="example-side">
          demo3:多选
        </div>
      </a-col>
      <a-col :span="8">
        <div class="example-side">
          <!--------------------------------------------------------------------------------------demo3---start-->
          <a-select
            mode="multiple"
            placeholder="请选择类型"
            style="width: 60%;"
            v-model="demo3.select1"
          >
            <a-select-option :key="index" :value="item.value" v-for="(item,index) in typeList">{{ item.label }}
            </a-select-option>
          </a-select>
          <!--------------------------------------------------------------------------------------demo3---end-->
          <a-button @click="() => demo3.select1 = undefined" style="margin-left: 8px">重置</a-button>
        </div>
      </a-col>
      <a-col :span="12" class="example-side">
        <div>
          当前选择: {{ demo3.select1 }}
        </div>
      </a-col>
    </a-row>

    <a-row style="margin-bottom: 10px">
      <a-col :span="4">
        <div class="example-side">
          demo4:可搜索
        </div>
      </a-col>
      <a-col :span="8">
        <div class="example-side">
          <!--------------------------------------------------------------------------------------demo4---start-->
          <a-select
            :filterOption="filterOption"
            :options="typeList"
            placeholder="请选择类型"
            showSearch
            style="width: 60%"
            v-model="demo4.select1"
          />
          <!--------------------------------------------------------------------------------------demo4---end-->
          <a-button @click="() => demo4.select1 = undefined" style="margin-left: 8px">重置</a-button>
        </div>
      </a-col>
      <a-col :span="12" class="example-side">
        <div>
          当前选择: {{ demo4.select1 }}
        </div>
      </a-col>
    </a-row>
  </a-card>
</template>

<script>
export default {
  name: 'OrdinarySelectBox',
  data () {
    return {
      typeList: [
        {
          value: 1,
          label: '可回收辣鸡'
        },
        {
          value: 2,
          label: '其他辣鸡'
        },
        {
          value: 3,
          label: '厨余辣鸡'
        },
        {
          value: 4,
          label: '有害辣鸡'
        }
      ],
      demo1: {
        select1: undefined
      },
      demo2: {
        select1: undefined
      },
      demo3: {
        select1: []
      },
      demo4: {
        select1: undefined
      }
    }
  },
  methods: {
    filterOption (input, option) {
      return (
        option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
      )
    }
  }
}
</script>

<style scoped>
</style>
